<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>let</title>
</head>

<body>
    <script>
        //let声明变量 let a = 100;

        //1  let变量不能重复声明   var可以
        var age = 18;
        var age = 20;
        console.log(age);   //20
        // let name = 'sun';
        // let name = 'wang';    会报错

        //2  块级作用域  
        // { let num = 1; }
        // console.log(num);   //未定义 读取不到

        //3  不存在变量提升
        // console.log(song);       //报错
        // let song = '最炫民族风';

        //4  不影响作用域链
        {
            let num = 111;
            function fn() {
                console.log(num);   //函数体内没有num，就向上一级找
            }
            fn();
        }

    </script>

</body>

</html>